package top.tangyh.lamp.care.mapper;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BHl7YzLisResult;
import org.springframework.stereotype.Repository;
import top.tangyh.lamp.care.vo.query.LisDetailQueryVO;
import top.tangyh.lamp.care.vo.query.YzListResultQueryVO;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 检验结果表
 * </p>
 *
 * @author zqb
 * @date 2024-08-02 16:39:32
 * @create [2024-08-02 16:39:32] [zqb] [代码生成器生成]
 */
@Repository
public interface BHl7YzLisResultMapper extends SuperMapper<BHl7YzLisResult> {

    default List<BHl7YzLisResult> selectListByQuery(YzListResultQueryVO queryVO) {
        String patientIdent = queryVO.getPatientIdent();
        String hospitalNumber = queryVO.getHospitalNumber();
        String orderId = queryVO.getOrderId();
        LambdaQueryWrapper<BHl7YzLisResult> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StrUtil.isNotBlank(patientIdent), BHl7YzLisResult::getPatientIdent, patientIdent)
                .eq(StrUtil.isNotBlank(hospitalNumber), BHl7YzLisResult::getHospitalNumber, hospitalNumber)
                .eq(StrUtil.isNotBlank(orderId), BHl7YzLisResult::getOrderId, orderId);
        return this.selectList(queryWrapper);
    }


    default List<BHl7YzLisResult> selectListDetailByQuery(LisDetailQueryVO queryVO) {
        String patientIdent = queryVO.getPatientIdent();
        String hospitalNumber = queryVO.getHospitalNumber();
        List<String> projectList = queryVO.getProjectList();
        String reportName = queryVO.getReportName();
        LambdaQueryWrapper<BHl7YzLisResult> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StrUtil.isNotBlank(patientIdent), BHl7YzLisResult::getPatientIdent, patientIdent)
                .eq(StrUtil.isNotBlank(hospitalNumber), BHl7YzLisResult::getHospitalNumber, hospitalNumber)
                .in(CollectionUtil.isNotEmpty(projectList), BHl7YzLisResult::getProjectIdent, projectList)
                .eq(StrUtil.isNotBlank(reportName), BHl7YzLisResult::getReportName, reportName)
                .orderByDesc(BHl7YzLisResult::getTakeTime);
        return this.selectList(queryWrapper);
    }


}


